
EELDIR := $(realpath $(KMOD_DIR)/../..)

-include $(KMOD_DIR)/.tmp.config.mk

ifeq ($(HOST),1)	# host build
ifeq ($(KERNELVERSION),)
KL_RELEASE				?= $(shell uname -r)
S_KL_DIR				= /lib/modules/$(KL_RELEASE)/build
JOB_OPT					= -j$(shell nproc)
endif
else # build depends on EEL config
-include $(EELDIR)/.tmp.config.mk
#### config mk start ####
include $(wildcard $(EELDIR)/arch/$(ARCH)/*.mk)

# arm or arm64
ifneq ($(findstring arm,$(ARCH)),)
include $(wildcard $(EELDIR)/configs/arm/*.mk)
endif

# riscv32 or riscv64
ifneq ($(findstring riscv,$(ARCH)),)
include $(wildcard $(EELDIR)/configs/riscv/*.mk)
endif

# ARCH config may need ovelay configs
include $(wildcard $(EELDIR)/configs/*.mk)
#### config mk end ####
endif	# end EEL

ifeq ($(KM_BASE),)
ifneq ($(KMOD_DIR),$(PWD))
KM_BASE = $(word 1,$(subst /, ,$(subst $(KMOD_DIR)/,,$(PWD))))
else
$(error Please define KM_BASE)
endif
endif

export KM_BASE

ccflags-y += -I $(KMOD_DIR)/$(KM_BASE)/inc
ccflags-y += -include $(KMOD_DIR)/$(KM_BASE)/inc/print_fmt.h
# enable dynamic debug while insmod/modprobe
ccflags-y += -DDEBUG
